strs = raw_input().split(' ')
next = {}
strs.sort(key=lambda s:len(s))
dp = {}
for s in strs:
    root = next
    for c in s:
        if c not in root:
            root[c]={}
        root = root[c]
    root['end']=None

def count(s):
    if s in dp: return dp[s]
    if len(s)==0: return 1
    sum = 0
    root = next
    for i, c in enumerate(s):
        if 'end' in root:
            sum += count(s[i:])
        if c in root: root = root[c]
        else: return 0
    if 'end' in root: return sum+1
    return sum

for s in strs:
    if s not in dp:
        dp[s]=count(s)

f = [key for key, value in dp.items() if value>1]
print(max(f,key=len))